#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d", &n);
	int arr[5] = { 0 };
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &arr[i]);
	}
	int len = sizeof(arr) / sizeof(arr[0]);
	int right = len - 1;
	int left = 0;
	while (left < right)
	{
		int mid = left + ((right - left) >> 1);
		if (arr[mid] > arr[right])
		{
			left = mid + 1;
		}
		else if (arr[mid] < arr[right])
		{
			right = mid;
		}
		else
		{
			right--;
		}
	}
	printf("%d", arr[left]);
}